package yzy.test.starter;

import yzy.test.beans.BeanFactory;
import yzy.test.core.ClassScanner;
import yzy.test.web.handler.HandlerManager;

import java.io.IOException;
import java.util.List;

public class MiniApplication {
    public static void run(Class<?> cls, String[] args){
        System.out.println("MiniApplication.run");

        /**
         * 这包扫描需要在命令行里面执行 java -jar test.jar才能正确扫描到,直接执行main方法获取不到的....
         */
        try {
            List<Class<?>> classList = ClassScanner.scanClasses(cls.getPackage().getName());
            classList.forEach(System.out::println);
            //解析所有的controller的元信息，@RequestMapping
            HandlerManager.resovleMappingHandler(classList);
            //初始化所有的bean 和 controller
            BeanFactory.initBean(classList);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
